package com.ruoyi.web.operate.issue.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.operate.issue.service.IIssueApprovalService;
import com.ruoyi.web.publish.issue.domain.IssueHistory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 发行审核 controller
 *
 * @author liuyu
 */
@RestController
@RequestMapping("/operate/issue/approval")
public class IssueApprovalController extends BaseController {

    @Autowired
    private IIssueApprovalService iIssueApprovalService;

    /**
     * 查询发行审核列表
     */
    @GetMapping("/list")
    public TableDataInfo list(IssueHistory issueHistory) {
        startPage();
        List<IssueHistory> list = iIssueApprovalService.selectApprovalIssueHistoryList(issueHistory);
        return getDataTable(list);
    }

    /**
     * 获取发行历史详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(iIssueApprovalService.selectIssueHistoryById(id));
    }

    /**
     * 修改发行历史
     */
    @Log(title = "发行", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult approval(@RequestBody IssueHistory issueHistory) {
        return toAjax(iIssueApprovalService.approvalIssueHistory(issueHistory));
    }
}
